package contents.entities;

import java.util.Comparator;

public class SubstitutionToSolve {
    public static class ByDateClassNameAndTimeComparator implements Comparator {
        public int compare(Object object1, Object object2) {
            SubstitutionToSolve substitution1 = (SubstitutionToSolve) object1;
            SubstitutionToSolve substitution2 = (SubstitutionToSolve) object2;
            
            java.util.Date date1 = substitution1.getAbsence().getDate();
            java.util.Date date2 = substitution2.getAbsence().getDate();
            
            if (!date1.equals(date2)) {
                return date1.compareTo(date2);
            } else {
                Class schoolClass1 = substitution1.getTimetable().getTimetableClass();
                Class schoolClass2 = substitution2.getTimetable().getTimetableClass();
                
                if (schoolClass1.getClassId() != schoolClass2.getClassId()) {
                    return schoolClass1.getName().compareTo(schoolClass2.getName());
                } else {
                    Integer time1 = substitution1.getTimetable().getTime();
                    Integer time2 = substitution2.getTimetable().getTime();
                    
                    return time1.compareTo(time2);
                }
            }
        }   
    }
    
    private Timetable timetable;
    private Absence absence;

    public SubstitutionToSolve(Timetable timetable, Absence absence) {
        this.timetable = timetable;
        this.absence = absence;
    }

    public Absence getAbsence() {
        return absence;
    }

    public Timetable getTimetable() {
        return timetable;
    }
}
